<?php
/**
 * Created by PhpStorm.
 * User: zhangrongxiang
 * Date: 2018/2/14
 * Time: 上午10:06
 */

$stack = array( "orange", "banana", "apple", "raspberry" );
$fruit = array_pop( $stack );
print_r( $stack );
echo $fruit . PHP_EOL;

$arr    = [
	[ 1, 2 ],
	[ 3, 4 ],
	[ 5, 6 ]
];
$result = array_pop( $arr );
print_r( $arr );
print_r( $result );

$arr = [ 0, '', ' ', null, false, '0', true ];
print_r( $arr );
while ( count( $arr ) ) {
	$result = array_pop( $arr );
	echo '>>' . $result . '<<' . PHP_EOL;
}
$a     = array_pad( [], 1000000, 1 );
$start = microtime( true );
while ( $num = count( $a ) ) {
	array_pop( $a );
}
$end = microtime( true );
echo $end - $start . PHP_EOL;//0.076108932495117
print_r($a);

$a     = array_pad( [], 1000000, 1 );
$start = microtime( true );
while ( $num = count( $a ) ) {
	unset( $a[ $num - 1 ] );
}
$end = microtime( true );
echo $end - $start . PHP_EOL;//0.064579963684082

print_r($a);
